package PackageIO;

import java.io.*;
import java.util.Scanner;

public class Test02 {
    public Test02(){
//        2：将用户输入的10个整数存入文件，然后输出文件长度。（提示，用DataoutputStream类或RandomAccessFile类写出）
        try {
            File file = new File("SchoolTest/src/PackageIO/test02.txt");
            DataOutputStream dos = new DataOutputStream(new FileOutputStream(file));
            DataInputStream dis = new DataInputStream(new FileInputStream(file));
            Scanner sca = new Scanner(System.in);
            for (int i = 0; i < 10; i++) {
                dos.writeInt(sca.nextInt());
            }
            System.out.println("文件的长度为： " + file.length());
            dos.close();
            dis.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public static void main(String[] args) {
        new Test02();
    }
}
